<template>
  <div class="box">
    <el-table
      :data="tableData"
      @row-click="handleRowClick"
      style="width: 100%">
      <el-table-column
        prop="targetname"
        label="用户名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="sex"
        label="性别"
        width="180">
      </el-table-column>
      <el-table-column
        prop="lasttime"
        label="上次聊天时间"
        >
      </el-table-column>
      <el-table-column
        prop="count"
        label="未读消息条数"
        width="180">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {GetContacts} from '@/request/api'
import { mapMutations } from 'vuex'
export default {
  data(){
    return{
      tableData:[]
    }
  },
  async created(){
    // let res = await GetAllLike()
    // this.tableData = res.data.data
    let res = await GetContacts()
    this.tableData = res.data.data
    this.tableData.forEach(item=>{
     if(item.sex == '0'){
      item.sex = '女'
     } else{
      item.sex = '男'
     }
    })
  },
  methods:{
    ...mapMutations({
      setShowChat:'chatStatus/setShowChat'
    }),
    handleRowClick(row,column,event){
      this.$router.push({path:'/other/chat',query:{userid:row.targetid}})
      this.setShowChat(true)
    }
  }
}
</script>

<style scoped>

</style>
